package com.zzk.lanouhn.myapplication1.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.zzk.lanouhn.myapplication1.R;
import com.zzk.lanouhn.myapplication1.modles.SingleGoodDetails;

/**
 *
 * 单品详情页面，各商家报价情况适配器
 * Created by lanouhn on 16/9/12.
 */
public class SingleGoodPriceAdapter extends RecyclerView.Adapter<SingleGoodPriceAdapter.priceViewHolder>{

    private Context context;
    private SingleGoodDetails singleGoodDetails;

    public SingleGoodPriceAdapter(Context context, SingleGoodDetails singleGoodDetails) {
        this.context = context;
        this.singleGoodDetails = singleGoodDetails;
    }

    @Override
    public priceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.item_price_singlegood,null);
        priceViewHolder holder=new priceViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(priceViewHolder holder, int position) {
        SingleGoodDetails.DataBean.PurchaseWayBean bean=singleGoodDetails.getData().getPurchase_way().get(position);
        holder.tv_name.setText(bean.getName()+": ￥");
        holder.tv_price.setText(bean.getPrice());
        Picasso.with(context).load(bean.getPic()).into(holder.iv_icon);
    }

    @Override
    public int getItemCount() {
        return singleGoodDetails.getData().getPurchase_way().size();
    }

    public class priceViewHolder extends RecyclerView.ViewHolder{

        private ImageView iv_icon,iv_to;
        private TextView tv_name,tv_price;
        public priceViewHolder(View itemView) {
            super(itemView);
            iv_icon= (ImageView) itemView.findViewById(R.id.Image_act_shopdetails);
            iv_to= (ImageView) itemView.findViewById(R.id.to_one_act_shopdetails);
            tv_name= (TextView) itemView.findViewById(R.id.name_act_shopdetails);
            tv_price= (TextView) itemView.findViewById(R.id.Price_act_shopdetails);
        }
    }
}
